package concurrent;

import lombok.extern.slf4j.Slf4j;

/**
 * @author fengpeng
 * @date 2019-08-29  19:07
 */
@Slf4j
public class InterruptDemo {


    private static class MyThread1 extends Thread {
        @Override
        public void run() {
            try {
                Thread.sleep(2000);
                log.info("Thread run");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    private static class MyThread2 extends Thread {
        @Override
        public void run() {
            while (!interrupted()) {
                // ...
                log.info("Thread is Running! ");
            }
            log.info("Thread end");
        }
    }




    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new MyThread1();
        thread1.start();
        thread1.interrupt();
        Thread thread2 = new MyThread2();
        thread2.start();
        thread2.interrupt();
       log.info("Main run");
    }




}
